package com.power.sifa.std.model;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
*  申请所需材料实体类
*/

@Entity
@ApiModel(value="申请所需材料")
@Data
@Table(name="Std_matter_attach",schema="sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
//@IdClass(Std_matter_attach.Std_matter_attachPK.class) 用于复合组件
public class Std_matter_attach extends BaseModel implements Serializable {

	private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "序号")
    private String id;

    @Column(nullable = false)
    @ApiModelProperty(value = "事项id")
    private String matid;

    @Column(nullable = false)
    @ApiModelProperty(value = "引用材料库id")
    private String attachid;

    @Column(nullable = false)
    @ApiModelProperty(value = "顺序号")
    private Integer sortnum;

    @Column(nullable = false)
    @ApiModelProperty(value = "是否必传")
    private Integer require;

    @Column(nullable = false)
    @ApiModelProperty(value = "最大上传数量")
    private Integer maxnum;

    @Column(nullable = false)
    @ApiModelProperty(value = "是否生成下载文件")
    private Integer filedown;

    @ApiModelProperty(value = "文件生成方式")
    private String filemake;

    @Column(nullable = false)
    @ApiModelProperty(value = "文件是否验证")
    private Integer fileverify;

    @ApiModelProperty(value = "模板名称")
    private String tplfile;

    @ApiModelProperty(value = "单个附件最大大小（单位：M）")
    private Integer maxfilesize;

    /**
     *  是否必传文本
     */
    @Transient
    @FieldEnumText(eum="yesNo", valuefield="require")
    private String require_text;

    /**
     *  是否生成下载文件文本
     */
    @Transient
    @FieldEnumText(eum="yesNo", valuefield="filedown")
    private String filedown_text;

    /**
     *  文件是否验证文本
     */
    @Transient
    @FieldEnumText(eum="yesNo", valuefield="fileverify")
    private String fileverify_text;


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("matid", this.getMatid());
        map.put("attachid", this.getAttachid());
        map.put("sortnum", this.getSortnum());
        map.put("require_text", this.require_text);
        map.put("require", this.getRequire());
        map.put("maxnum", this.getMaxnum());
        map.put("filedown_text", this.filedown_text);
        map.put("filedown", this.getFiledown());
        map.put("filemake", this.getFilemake());
        map.put("fileverify_text", this.fileverify_text);
        map.put("fileverify", this.getFileverify());
        map.put("tplfile", this.getTplfile());
        map.put("maxfilesize", this.getMaxfilesize());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Std_matter_attachPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String)key;

        //Std_matter_attachPK pk = (Std_matter_attachPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}
